<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>用户登陆</title>
    <link rel="stylesheet" href="/css/styles.css">
    <style>
        body {
            background-image: url("img/lp.png");
            background-size: cover;
            color: #fff;
            font-family: Arial, sans-serif;
        }
        form {
            max-width: 300px;
            margin: 50px auto;
        }
        input {
            width: 100%;
            padding: 10px;
            margin-bottom: 10px;
        }
        button {
            background-color: #4CAF50;
            width: 150px;
            color: white;
            padding: 15px 15px;
            border: none;
            cursor: pointer;
        }

    </style>
</head>
<body>


<form method="post" action="">
    <h2>用户登陆</h2>

    <?php
    // 处理登录逻辑
    if ($_SERVER["REQUEST_METHOD"] == "POST") {
        $username = $_POST["username"];
        $password = $_POST["password"];
        include "conn.php";
        // 进行简单的验证，实际项目需要更严格的安全性处理
        $sql = "SELECT * FROM users WHERE uname = '$username' AND upwd = '$password'";
        $result = $conn->query($sql);
        $flag = $result->num_rows;
        if ($flag) {
            // 用户验证成功
            echo "<script>alert('登陆成功！！！,正在跳转'); window.location.href='news.php';</script>";
        } else {
            // 用户验证失败
            echo "<script>alert('用户名或者密码错误！！！');</script>";
        }
    }
?>




        <label for="username">用户:</label>
    <input type="text" id="username" name="username" required style="width: 300px"><br>

    <label for="password">密码:</label>
    <input type="password" id="password" name="password" required style="width: 300px"><br>
    <a href="./register.php">没有账号？去注册</a>

    <input type="submit" value="Login" name="提交登录"  required style="width: 325px"><br>


</form>
</body>
</html>
